package com.xd.study.utility;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xd.study.R;

import java.util.List;

/**
 * Created by DGF on 2015/5/7.
 */
public class GestureBuilderAdapter extends BaseAdapter {

    private Context context;
    private List<String> names;
    private List<Bitmap> bitmaps;

    public GestureBuilderAdapter(Context context, List<String> gestureNames, List<Bitmap> gestureBitmaps){
        this.context = context;
        this.names = gestureNames;
        this.bitmaps = gestureBitmaps;
    }

    @Override
    public int getCount() {
        return this.names.size();
    }

    @Override
    public Object getItem(int position) {
        return names.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        convertView = LayoutInflater.from(context).inflate(R.layout.gesture_builder_list_item, null);

        ImageView imageView = (ImageView)convertView.findViewById(R.id.gesture_builder_list_image);
        imageView.setImageBitmap(bitmaps.get(position));

        TextView textView = (TextView)convertView.findViewById(R.id.gesture_builder_list_text);
        textView.setText(names.get(position));

        return convertView;
    }
}
